import { clearCustomerServiceGroup, changeCustomerServiceList } from './api'
import { ElMessage, ElMessageBox } from 'element-plus'
export function onClearCustomerServiceGroup(ctx) {
  const row = ctx.props.row
  clearCustomerServiceGroup({userId: row.userId,}).then(() => {
    ctx._c.dispatch('ListPage', 'getData')
  })
}

export async function changeBlacklist(ctx) {
  const row = ctx.props.row
  await ElMessageBox.confirm(`是否确定${row.listName === '黑' ? '取消' : '添加'}黑名单？`, '提示')
  changeCustomerServiceList({
    userId: row.userId,
    listName: row.listName === '黑' ? '' : '黑'
  }).then(() => {
    ElMessage.success('操作成功')
    ctx._c.dispatch('ListPage', 'getData')
  })
}

export async function changeWhitelist(ctx) {
  const row = ctx.props.row
  await ElMessageBox.confirm(`是否确定${row.listName === '白' ? '取消' : '添加'}白名单？`, '提示')
  changeCustomerServiceList({
    userId: row.userId,
    listName: row.listName === '白' ? '' : '白'
  }).then(() => {
    ElMessage.success('操作成功')
    ctx._c.dispatch('ListPage', 'getData')
  })
}
